﻿using FileUtility;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace TestProject
{
    
    
    /// <summary>
    ///This is a test class for ExtStringDataControllerTest and is intended
    ///to contain all ExtStringDataControllerTest Unit Tests
    ///</summary>
    [TestClass()]
    public class ExtStringDataControllerTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for Split
        ///</summary>
        [TestMethod()]
        public void SplitTest()
        {
            string strLine = "0001023456789"; // TODO: Initialize to an appropriate value
            int[] unitLengthArr = { 5, 5, 3 }; // TODO: Initialize to an appropriate value
            string[] expected = { "10", "23456", "789" }; // TODO: Initialize to an appropriate value
            string[] actual;
            actual = ExtString.Split(strLine, unitLengthArr, null);
            Assert.AreEqual(expected[2], actual[2]);

        }

        /// <summary>
        ///A test for Split
        ///</summary>
        [TestMethod()]
        public void SplitTest1()
        {

            string strLine = "10005060789"; // TODO: Initialize to an appropriate value
            int[] unitLengthArr = { 1, 7, 3 }; // TODO: Initialize to an appropriate value
            string[] expected = { "1", "5060", "789" }; // TODO: Initialize to an appropriate value
            string[] actual;
            actual = ExtString.Split(strLine, unitLengthArr, null);
            Assert.AreEqual(expected[1], actual[1]);
            Assert.AreEqual(expected[2], actual[2]);
        }

        [TestMethod()]
        public void TestGeneicConvert()
        {
            System.Collections.Generic.List<int> listInt = new System.Collections.Generic.List<int>();
            listInt.Add(1);
            listInt.Add(2);
            listInt.Add(3);
            System.Collections.Generic.List<float> listFloat = listInt.ConvertAll<float>(i => (float)i);
            listFloat.ForEach(f => Console.WriteLine(f));

            System.Globalization.GregorianCalendar gc = new System.Globalization.GregorianCalendar();
           int weekOfYear = gc.GetWeekOfYear(DateTime.Now, System.Globalization.CalendarWeekRule.FirstDay, DayOfWeek.Monday);//0:sunday,1:monday 
            string week = Convert.ToString(weekOfYear);
            if (week.Length == 1)
            {
                week = '0' + week;
            }
            //DateCode = DateTime.Now.Year.ToString().Substring(2, 2) + week;
        }
    }
}
